import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import About from '../views/About.vue'
import Contact from '../views/Contact.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    meta: {
      backgroundImage: 'https://objectstorageapi.bja.sealos.run/g6rnmc1y-yunshang/wan_ip/123.jpg'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: About,
    meta: {
      backgroundImage: 'https://objectstorageapi.bja.sealos.run/g6rnmc1y-yunshang/wan_ip/about-bg.jpg'
    }
  },
  {
    path: '/contact',
    name: 'Contact',
    component: Contact,
    meta: {
      backgroundImage: 'https://objectstorageapi.bja.sealos.run/g6rnmc1y-yunshang/wan_ip/contact-bg.jpg'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes,
  scrollBehavior(to, from, savedPosition) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          top: savedPosition?.top || 0,
          behavior: 'smooth'
        })
      }, 500)
    })
  }
})

export default router